kruskal裸题
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define N 1010
#define pa pair<int,int>
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
return x*f;
}
int n,fa[N],m,num=0;
double ans=0;
struct Edge{
int x,y;ll val;
}e[N*N];
struct point{
int x,y;
}p[N];
inline int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
inline void add(int x,int y,ll val){
e[++num].x=x;e[num].y=y;e[num].val=val;
}
inline bool cmp(Edge x,Edge y){
return x.val<y.val;
}
int main(){
// freopen("a.in","r",stdin);
n=read();m=read();
for(int i=1;i<=n;++i){
p[i].x=read(),p[i].y=read();fa[i]=i;
for(int j=1;j<i;++j)
add(i,j,(ll)(p[i].x-p[j].x)*(p[i].x-p[j].x)+(ll)(p[i].y-p[j].y)*(p[i].y-p[j].y));
}sort(e+1,e+num+1,cmp);
for(int i=1;i<=m;++i){
int x=read(),y=read();
int xx=find(x),yy=find(y);if(xx!=yy) fa[xx]=yy;
}
for(int i=1;i<=num;++i){
int xx=find(e[i].x),yy=find(e[i].y);
if(xx!=yy){
fa[xx]=yy;ans+=sqrt(e[i].val);
}
}printf("%.2f\n",ans);
return 0;
}